package com.dudu.music.bridge;

import android.os.Parcel;
import android.os.Parcelable;

public class Music implements Parcelable {
    public static final int VERSION = 10000;

    public static final Creator<Music> CREATOR = new Creator<Music>() {
        @Override
        public Music createFromParcel(Parcel in) {
            return new Music(in);
        }

        @Override
        public Music[] newArray(int size) {
            return new Music[size];
        }
    };
    private int index;//当前列表位置
    private String title;//标题
    private String songer;//歌手
    private String cover;//封面URL,或者是本地文件PATH，保证桌面可读取
    private String path;//歌曲文件地址
    private int total;//歌曲长度

    protected Music(Parcel in) {
        int nowVersion = in.readInt();
        //第一个int默认为版本号，为了保证后期扩展性
        if (nowVersion == 10000) {
            index = in.readInt();
            cover = in.readString();
            title = in.readString();
            songer = in.readString();
            total = in.readInt();
            path = in.readString();
        }
    }

    public Music() {
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(VERSION);
        dest.writeInt(index);
        dest.writeString(cover);
        dest.writeString(title);
        dest.writeString(songer);
        dest.writeInt(total);
        dest.writeString(path);
    }

    public int getIndex() {
        return index;
    }

    public Music setIndex(int index) {
        this.index = index;
        return this;
    }

    public String getTitle() {
        return title;
    }

    public Music setTitle(String title) {
        this.title = title;
        return this;
    }

    public String getSonger() {
        return songer;
    }

    public Music setSonger(String songer) {
        this.songer = songer;
        return this;
    }

    public String getCover() {
        return cover;
    }

    public Music setCover(String cover) {
        this.cover = cover;
        return this;
    }

    public String getPath() {
        return path;
    }

    public Music setPath(String path) {
        this.path = path;
        return this;
    }

    public int getTotal() {
        return total;
    }

    public Music setTotal(int total) {
        this.total = total;
        return this;
    }
}
